import { createStore } from 'vuex'
import persistedState from "vuex-persistedstate";
export default createStore({
  state: {
    isGetterRouter: false,
    isCollapsed: false,
    userInfo: {},
  },
  getters: {
  },
  mutations: {
    changeGetterRouter(state, value) {
      state.isGetterRouter = value
    },
    // 控制是否折叠slideBar
    changeCollasped(state) {
      state.isCollapsed = !state.isCollapsed
    },
    changeUserInfo(state, value) {
      state.userInfo = {
        ...state.userInfo,
        ...value
      }
    },
    clearUserInfo(state) {
      state.userInfo = {}
    }
  },
  actions: {
  },
  modules: {
  },
  // 持久化插件
  plugins: [persistedState({
    // 只让折叠持久化
    paths: ["isCollapsed", "userInfo"]
  })]
})
